package com.example.yz.happywoker;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.avos.avoscloud.AVUser;
import com.example.yz.happywoker.lib.ActivityList;

public class SettingActivity extends Activity implements View.OnClickListener{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_setting);
        ActivityList.getInstance().addActivity(this);
        init();
    }

    private void init() {
        Button logoffBtn = (Button) findViewById(R.id.log_off);
        logoffBtn.setOnClickListener(this);
        ImageView setting_back = (ImageView) findViewById(R.id.setting_back);
        setting_back.setOnClickListener(this);

        RelativeLayout userSetting = (RelativeLayout) findViewById(R.id.userSettingIntent);
        userSetting.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.log_off:
                AVUser.logOut();// 清除缓存用户对象
                Intent intent = new Intent();
                intent.setClass(SettingActivity.this, LoginActivity.class);
                startActivity(intent);

                ActivityList.getInstance().FinishAll();
                break;
            case R.id.userSettingIntent:
                Intent intent0 = new Intent();
                intent0.setClass(SettingActivity.this, UserSettingAgreeMentActivity.class);
                startActivity(intent0);
                break;

            case R.id.setting_back:
                finish();
                break;

        }
    }
}

